package com.heart.house.api.validation;


import com.heart.house.api.common.ResultMsg;
import com.heart.house.api.model.User;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Component;

/**
 * @author Luo Zhen
 * @create 2019-06-13 11:47
 */
@Component
public class UserHelper {

    public ResultMsg validate(User account) {
        if (StringUtils.isBlank(account.getEmail())) {
            return ResultMsg.errorMsg("邮箱不能为空");
        }
        if (StringUtils.isBlank(account.getName())) {
            return ResultMsg.errorMsg("名字不能为空");
        }
        if (StringUtils.isBlank(account.getConfirmPasswd()) || StringUtils.isBlank(account.getPasswd())) {
            return ResultMsg.errorMsg("密码不能为空");
        }
        if (account.getPasswd().length() < 6) {
            return ResultMsg.errorMsg("密码大于6位");
        }
        return ResultMsg.successMsg("");
    }

}
